package com.kh.pajx.sop.service.sys.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kh.pajx.sop.base.BaseServiceImpl;
import com.kh.pajx.sop.dao.sys.ISysDeptAreaDao;
import com.kh.pajx.sop.domain.PageBean;
import com.kh.pajx.sop.domain.SysDeptArea;
import com.kh.pajx.sop.service.sys.ISysDeptAreaService;
import com.kh.pajx.sop.util.page.QueryHelper;
import com.kh.pajx.sop.util.page.QueryHelperForManyTable;
@Service
@Transactional
public class SysDeptAreaServiceImpl extends BaseServiceImpl<SysDeptArea>
		implements ISysDeptAreaService {
	@Resource
	ISysDeptAreaDao sysDeptAreaDao;
	
	@Override
	public void save(SysDeptArea demo) {
		sysDeptAreaDao.save(demo);
	}

	@Override
	public void delete(String uuid) {
		sysDeptAreaDao.delete(uuid);
	}


	@Override
	public SysDeptArea getById(String uuid) {
		return sysDeptAreaDao.getById(uuid);
	}



	@Override
	public List<SysDeptArea> getSysDeptAreaByDeptCode(String deptCode) {
		return sysDeptAreaDao.getSysDeptAreaByDeptCode(deptCode);
	}

	@Override
	public void updateDeptArea(List<SysDeptArea> deptAreaList,
			List<SysDeptArea> newDeptAreaList) {
		try {
			for(SysDeptArea deptArea:deptAreaList){//将原关系删除
				delete(deptArea.getDeptAreaId());
			}
			for(SysDeptArea deptArea:newDeptAreaList){//添加新关系添加
				save(deptArea);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public List<String> getAreaCodeByDeptCode(String deptCode) throws Exception {
		return sysDeptAreaDao.getAreaCodeByDeptCode(deptCode);
	}

}
